<template>
  <div class="app">
    <div class="smooth-curve">
      <div class="baseinfobox" @click="editPerson">
        <div class="avatar">
          <img v-if="image != null" :src="image" alt="" />
          <img v-if="image == null" src="../../../public/user.jpeg" alt="" />
        </div>
        <div class="textinfo">
          <div class="accountname">{{ nickname }}</div>
          <div class="accountinfo">简介:{{ description }}</div>
        </div>
      </div>
      <div class="three-number">
        <div class="number" @click="gotolink('/userfollowsandfans')">
          <div class="num">123</div>
          <div class="text">我的关注</div>
        </div>
        <div class="number" @click="gotolink('/userfollowsandfans')">
          <div class="num">123</div>
          <div class="text">粉丝</div>
        </div>
        <div class="number">
          <div class="num">0</div>
          <div class="text">获赞</div>
        </div>
      </div>

      <div class="vip-box">
        <div class="vip-image-box">
          <icon-svg
            icon-class="vipicon"
            style="width: 50px; height: 50px"
          ></icon-svg>
        </div>
        <div class="vip-text-box">
          <div class="vip-title">会员专享</div>
          <div class="vip-info">XXXXXXXXXXXXXX</div>
        </div>
        <div class="vip-button">立即开通</div>
      </div>

      <div class="remind-box">
        <div class="remind-item" @click="gotolink('/noticepage')">
          <div class="remind-icon">
            <icon-svg
              icon-class="message"
              style="width: 20px; height: 20px"
            ></icon-svg>
          </div>
        </div>
      </div>
    </div>

    <div class="recommend-teacher-box">
      <div class="recommend-teacher-title">
        <div class="recommend-teacher-text">常用功能</div>
      </div>
      <el-card class="recommend-teacher-content" :body-style="{ padding: 0 }">
        <van-grid :column-num="3" :border="true">
          <van-grid-item @click="gotolink('./mywallet')">
            <icon-svg
              icon-class="myaccount"
              style="width: 1.25rem; height: 1.25rem"
            ></icon-svg>
            <div class="store-box-text">我的账户</div>
          </van-grid-item>
          <van-grid-item @click="gotolink('./userorder')">
            <icon-svg
              icon-class="myorder"
              style="width: 1.25rem; height: 1.25rem"
            ></icon-svg>
            <div class="store-box-text">我的订单</div>
          </van-grid-item>
          <van-grid-item @click="gotolink('./mycollection')">
            <icon-svg
              icon-class="mycollect"
              style="width: 1.25rem; height: 1.25rem"
            ></icon-svg>
            <div class="store-box-text">我的收藏</div>
          </van-grid-item>
        </van-grid>
      </el-card>
    </div>

    <div class="recommend-teacher-box1">
      <div class="recommend-teacher-title">
        <div class="recommend-teacher-text">其他服务</div>
      </div>
      <el-card class="recommend-teacher-content" :body-style="{ padding: 0 }">
        <van-cell-group class="xxx">
          <van-cell title="申请教练" is-link to="/zhujiaoapply">
            <template #icon>
              <icon-svg
                icon-class="zhujiaoapply"
                style="width: 0.7rem; height: 0.7rem"
              ></icon-svg>
            </template>
          </van-cell>
          <van-cell title="核销劵码" is-link>
            <template #icon>
              <icon-svg
                icon-class="quanma"
                style="width: 0.7rem; height: 0.7rem"
              ></icon-svg>
            </template>
          </van-cell>
          <van-cell title="联系客服" is-link>
            <template #icon>
              <icon-svg
                icon-class="kefu"
                style="width: 0.7rem; height: 0.7rem"
              ></icon-svg>
            </template>
          </van-cell>
          <van-cell title="意见反馈" is-link to="/feedback">
            <template #icon>
              <icon-svg
                icon-class="fankui"
                style="width: 0.7rem; height: 0.7rem"
              ></icon-svg>
            </template>
          </van-cell>
          <van-cell title="版本升级" is-link>
            <template #icon>
              <icon-svg
                icon-class="update"
                style="width: 0.7rem; height: 0.7rem"
              ></icon-svg>
            </template>
          </van-cell>
          <van-cell title="设置" is-link to="/personsettings">
            <template #icon>
              <icon-svg
                icon-class="setting"
                style="width: 0.7rem; height: 0.7rem"
              ></icon-svg>
            </template>
          </van-cell>
        </van-cell-group>
      </el-card>
    </div>

    <div style="padding-bottom: calc(50px + env(safe-area-inset-bottom))" />
  </div>
</template>

<script>
import { useStore } from "@/store/index.js";
import { showImagePreview } from "vant";
export default {
  data() {
    return {
      userid: "",
      uid: "",
      showFlag: true,
      phone: "",
      nickname: "",
      image: "",
      description: "",
    };
  },
  methods: {
    inituserinfo() {
      const store = useStore();
      const userinfo = store.getUserStoreinfo;
      this.nickname = userinfo.nickname;
      this.phone = userinfo.phone;
      this.userid = userinfo.id;
      this.uid = userinfo.uid;
      this.image = userinfo.image;
      this.role_id = userinfo.role_id;
      this.description = userinfo.description;
    },
    showimg(image) {
      showImagePreview([image]);
    },
    showuserimg() {
      const img = require("../../../public/user.jpeg");
      showImagePreview([img]);
    },
    editPerson() {
      this.$router.push("/persondetails");
      // if (this.role_id == 5) {
      //   this.$router.push("/persondetails");
      // } else if (this.role_id == 4) {
      //   this.$router.push("/zhujiaoinfo");
      // }
    },
    gotolink(value) {
      this.$router.push(value);
    },
  },
  mounted() {
    this.inituserinfo();
  },
};
</script>

<style scoped>
.app {
  background-color: #f5f3f3;
}

.smooth-curve {
  width: 100%;
  height: 225px;
  background-image: url("../../assets/icons/user/mybackimg.svg");
  background-position: center;
  border-radius: 0 0 100% 100%/0 35px 35px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.baseinfobox {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 85%;
  margin: 50px auto 0 auto;
  font-size: 18px;
}

.baseinfobox .avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.textinfo {
  max-width: calc(100% - 75px);
  flex-grow: 1;
  margin-left: 15px;
  color: #f7f8fa;
}

.accountname {
  font-size: 20px;
}

.accountinfo {
  margin-top: 5px;
  font-size: 13px;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-all;
}

.three-number {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  position: absolute;
  bottom: 50px;
  left: 20px;
  width: 90%;
  font-size: 15px;
}

.number {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #f7f8fa;
  font-size: 13px;
}

.remind-box {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  position: absolute;
  top: 10px;
  right: 20px;
  width: 30px;
}

.vip-box {
  display: flex;
  flex-direction: row;
  align-items: center;
  position: absolute;
  top: 190px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  height: 75px;
  box-sizing: border-box;
  border: 2px solid white;
  background-color: #dce8fd;
  border-radius: 50px;
  padding: 5px;
}

.vip-image-box {
  margin: 20px;
  width: 60px;
  height: 60px;
  overflow: hidden;
  display: flex;
  align-items: center;
}

.vip-title {
  font-size: 18px;
  font-weight: 600;
  color: black;
}

.vip-info {
  font-size: 12px;
  color: black;
  margin-top: 5px;
}

.vip-button {
  margin-left: 45px;
  width: 80px;
  height: 30px;
  background-color: #f7f8fa;
  border-radius: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 15px;
  color: #8fc7f1;
  cursor: pointer;
}

.recommend-teacher-box {
  width: 90%;
  margin: 50px auto 0 auto;
}
.recommend-teacher-box1 {
  width: 90%;
  margin: 15px auto 0 auto;
}

.recommend-teacher-title {
  display: block;
  margin: 5px 0 5px 0;
  height: 25px;
}

.recommend-teacher-text,
.store-box-text {
  font-size: 18px;
  font-weight: 550;
  margin: 0 0 10px 0;
}

.recommend-teacher-content {
  margin-top: 10px;
  margin-bottom: 10px;
  border-radius: 10px !important;
}
</style>

<style>
.recommend-teacher-content van-grid {
  border-radius: 25px !important;
}
.xxx .van-cell__title {
  line-height: 0.7rem !important;
  margin-left: 5px;
  font-weight: 550 !important;
}
</style>